﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MediatR;

namespace ManagoMes.Read.API.Applications.WangDefa
{
    public class LoginHhtmlHandler:IRequestHandler<LoginHhtmlcommond, ResultsDTO<RecordsLogin>>
    {


        private readonly IBateRepository<RecordsLogin> _RecordsLogin;
        private readonly DapperHelper DapperHelper;

        public LoginHhtmlHandler(IBateRepository<RecordsLogin> recordsLogin)
        {
            _RecordsLogin = recordsLogin;
    
        }

        public async Task<ResultsDTO<RecordsLogin>> Handle(LoginHhtmlcommond request, CancellationToken cancellationToken)
        {

            try
            {
                var list = new ResultsDTO<RecordsLogin>() { Code = 0 };
                var str = "select * from login";
                var per = new RecordsLogin();
                DapperHelper dapperHelper = new DapperHelper();

              var  lists = _RecordsLogin.GetAll(str, per, dapperHelper.MangoMesRead).ToList();
                lists=lists.OrderByDescending(x => x.Logsid).ToList();
                list.Data = lists;
                return list;
            }
            catch (Exception)
            {

                throw;
            }
      
        }




    }
}
